/**
 * @file   NewickTreeFactory.h
 * @author Scanagatta Mauro - Alberto Franco
 *
 * Created on March 7, 2011, 10:57 PM
 */

#ifndef NEWICK_TREE_FACTORY_H
#define	NEWICK_TREE_FACTORY_H

#include <string>
#include <set>

#include "NewickTree.h"

namespace Biopool
{


/**
 * This class serialize and deserialize NewickTrees. We kept the serializing
 * part separately to logically distinguish between implementation and
 * persistency of the data.
 */
class NewickTreeFactory
{
public:

    /// Deserializing method
    static NewickTree* deserialize(std::string treeString);

    /// Serializing method
    static std::string serialize(NewickTree& tree);

private:

    // Method to descend into the tree
    static std::string treeDescend(NewickTree::Node*);

    // Serialize the integer set
    static std::string serializeSet(intSet*);    

    // Descend and deserialize the tree
    static NewickTree::Node* descendDeserialize(std::string::iterator&, std::string&);


}; // end class NewickTreeFactory <---------------------------------------------

} /* namespace */

#endif	/* NEWICK_TREE_FACTORY_H */
